package com.stepcleanse.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.stepcleanse.common.log.annotation.Log;
import com.stepcleanse.common.log.enums.BusinessType;
import com.stepcleanse.common.security.annotation.RequiresPermissions;
import com.stepcleanse.system.domain.RefundOrder;
import com.stepcleanse.system.service.IRefundOrderService;
import com.stepcleanse.common.core.web.controller.BaseController;
import com.stepcleanse.common.core.web.domain.AjaxResult;
import com.stepcleanse.common.core.utils.poi.ExcelUtil;
import com.stepcleanse.common.core.web.page.TableDataInfo;

/**
 * 退款订单Controller
 * 
 * @author stepcleanse
 * @date 2024-12-09
 */
@RestController
@RequestMapping("/refundorder")
public class RefundOrderController extends BaseController
{
    @Autowired
    private IRefundOrderService refundOrderService;

    /**
     * 查询退款订单列表
     */
    @RequiresPermissions("refund:order:list")
    @GetMapping("/list")
    public TableDataInfo list(RefundOrder refundOrder)
    {
        startPage();
        List<RefundOrder> list = refundOrderService.selectRefundOrderList(refundOrder);
        return getDataTable(list);
    }

    /**
     * 导出退款订单列表
     */
    @RequiresPermissions("refund:order:export")
    @Log(title = "退款订单", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, RefundOrder refundOrder)
    {
        List<RefundOrder> list = refundOrderService.selectRefundOrderList(refundOrder);
        ExcelUtil<RefundOrder> util = new ExcelUtil<RefundOrder>(RefundOrder.class);
        util.exportExcel(response, list, "退款订单数据");
    }

    /**
     * 获取退款订单详细信息
     */
    @RequiresPermissions("refund:order:query")
    @GetMapping(value = "/{refundOrderId}")
    public AjaxResult getInfo(@PathVariable("refundOrderId") String refundOrderId)
    {
        return success(refundOrderService.selectRefundOrderByRefundOrderId(refundOrderId));
    }

    /**
     * 新增退款订单
     */
    @RequiresPermissions("refund:order:add")
    @Log(title = "退款订单", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RefundOrder refundOrder)
    {
        return toAjax(refundOrderService.insertRefundOrder(refundOrder));
    }

    /**
     * 修改退款订单
     */
    @RequiresPermissions("refund:order:edit")
    @Log(title = "退款订单", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RefundOrder refundOrder)
    {
        return toAjax(refundOrderService.updateRefundOrder(refundOrder));
    }

    /**
     * 删除退款订单
     */
    @RequiresPermissions("refund:order:remove")
    @Log(title = "退款订单", businessType = BusinessType.DELETE)
	@DeleteMapping("/{refundOrderIds}")
    public AjaxResult remove(@PathVariable String[] refundOrderIds)
    {
        return toAjax(refundOrderService.deleteRefundOrderByRefundOrderIds(refundOrderIds));
    }
}
